package com.stm.basicData.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stm.basicData.mapper.FactoryLinkmanMapper;
import com.stm.basicData.domain.FactoryLinkman;
import com.stm.basicData.service.IFactoryLinkmanService;
import com.stm.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 厂家联系人 服务层实现
 *
 * @author wyc
 * @date 2019-04-08
 */
@Service
public class FactoryLinkmanServiceImpl implements IFactoryLinkmanService {
    @Autowired
    private FactoryLinkmanMapper factoryLinkmanMapper;

    /**
     * 查询厂家联系人信息
     *
     * @param id 厂家联系人ID
     * @return 厂家联系人信息
     */
    @Override
    public FactoryLinkman selectFactoryLinkmanById(String id) {
        return factoryLinkmanMapper.selectFactoryLinkmanById(id);
    }

    /**
     * 查询厂家联系人列表
     *
     * @param factoryLinkman 厂家联系人信息
     * @return 厂家联系人集合
     */
    @Override
    public List<FactoryLinkman> selectFactoryLinkmanList(FactoryLinkman factoryLinkman) {
        return factoryLinkmanMapper.selectFactoryLinkmanList(factoryLinkman);
    }

    /**
     * 新增厂家联系人
     *
     * @param factoryLinkman 厂家联系人信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertFactoryLinkman(FactoryLinkman factoryLinkman) {
        UUID uuid = UUID.randomUUID();
        factoryLinkman.setId(uuid.toString());
        factoryLinkman.setStatus("1");
        factoryLinkman.setCreateDate(new Date());
        return factoryLinkmanMapper.insertFactoryLinkman(factoryLinkman);
    }

    /**
     * 修改厂家联系人
     *
     * @param factoryLinkman 厂家联系人信息
     * @return 结果
     */
    @Override
    @Transactional
    public int updateFactoryLinkman(FactoryLinkman factoryLinkman) {
        factoryLinkman.setUpdateDate(new Date());
        return factoryLinkmanMapper.updateFactoryLinkman(factoryLinkman);
    }

    /**
     * 删除厂家联系人对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteFactoryLinkmanByIds(String ids) {
        return factoryLinkmanMapper.deleteFactoryLinkmanByIds(Convert.toStrArray(ids));
    }

}
